package love.baby;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.HashMap;
import java.util.concurrent.TimeoutException;

/**
 * @create: 2022-03-01 10:07
 * @description:
 **/

public class MqBase {
    public static String QUEUE_NAME = "MQ";
    public static Channel initChannel() throws IOException, TimeoutException {
        ConnectionFactory factory = new ConnectionFactory();
        factory.setUsername("xiaoq");
        factory.setPassword("xiaoq");
        factory.setHost("121.4.158.234");
        factory.setPort(5672);
        Connection connection = factory.newConnection();
        Channel channel = connection.createChannel();
        channel.queueDeclare(QUEUE_NAME,false,false,false,new HashMap<>());
        return channel;
    }
}
